;;; packages - package definitions for GNU Guix
;;; Copyright (C) 2017 ng0
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU Affero General Public License as
;;; published by the Free Software Foundation, either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU Affero General Public License for more details.
;;;
;;; You should have received a copy of the GNU Affero General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(define-module (ng0 packages vim)
  #:use-module (guix packages)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix git-download)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (gnu packages vim)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages python))

(define-public vim-nerdtree
  (let ((commit "281701021c5001332a862da80175bf585d24e2e8")
        (revision "1"))
    (package
      (name "vim-nerdtree")
      (version (string-append "0.0.0-" revision "." (string-take commit 7)))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/scrooloose/nerdtree")
               (commit commit)))
         (file-name (string-append name "-" version "-checkout"))
         (sha256
          (base32
           "0fp2rfz6rmaj01w5kifqzdyi934j20pa8bpgw13ks1s0s4x7xkck"))))
      (build-system gnu-build-system)
      (arguments
       `(#:tests? #f
         #:phases
         (modify-phases %standard-phases
           (delete 'configure)
           (delete 'build)
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (vimfiles (string-append out "/share/vim/vimfiles"))
                      (autoload (string-append vimfiles "/autoload"))
                      (plugin (string-append vimfiles "/plugin"))
                      (doc (string-append vimfiles "/doc"))
                      (syntax (string-append vimfiles "/syntax"))
                      (lib (string-append vimfiles "/lib"))
                      (nerdtree_plugin (string-append vimfiles "/nerdtree_plugin")))
                 (copy-recursively "autoload" autoload)
                 (copy-recursively "doc" doc)
                 (copy-recursively "plugin" plugin)
                 (copy-recursively "syntax" syntax)
                 (copy-recursively "lib" lib)
                 (copy-recursively "nerdtree_plugin" nerdtree_plugin)
                 #t))))))
      (synopsis "Filetree explorer plugin for Vim")
      (description
        "@code{vim-nerdtree} allows you to explore your filesystem and to
open files and directories.  It presents the filesystem to you in the form
of a tree which you manipulate with the keyboard and/or mouse.  It also
allows you to perform simple filesystem operations.")
      (home-page "https://github.com/scrooloose/nerdtree")
      (license license:wtfpl2))))


(define-public vim-latex
  (let ((commit "db1cc0ae9fea4981589f0a71432ec8ffc053ba78")
        (revision "1"))
    (package
      (name "vim-latex")
      (version (string-append "1.9.0-" revision "." (string-take commit 7)))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://github.com/vim-latex/vim-latex")
                 (commit commit)))
          (file-name (string-append name "-" version "-checkout"))
          (sha256
            (base32
              "18x2qmjlkichyjq407ch4k0jj7rk7hnrhhl1giwi9w5x4k983lcv"))))
      (build-system gnu-build-system)
      (arguments
        `(#:tests? #f
          #:phases
          (modify-phases %standard-phases
            (delete 'configure)
            (delete 'build)
            (replace 'install
              (lambda* (#:key outputs #:allow-other-keys)
                (let* ((out (assoc-ref outputs "out"))
                       (vimfiles (string-append out "/share/vim/vimfiles"))
                       (compiler (string-append vimfiles "/compiler"))
                       (doc (string-append vimfiles "/doc"))
                       (ftplugin (string-append vimfiles "/ftplugin"))
                       (indent (string-append vimfiles "/indent"))
                       (plugin (string-append vimfiles "/plugin"))
                       (bin (string-append out "/bin")))
                  (copy-recursively "compiler" compiler)
                  (copy-recursively "ftplugin" ftplugin)
                  (copy-recursively "doc" doc)
                  (copy-recursively "indent" indent)
                  (copy-recursively "plugin" plugin)
                  (install-file "ltags" bin)
                  (install-file "latextags" bin)
                  #t))))))
      (inputs
        `(("perl" ,perl)
          ("python-2" ,python-2)))
      (synopsis "Enhanced LaTeX support for Vim")
      (description
        "@code{vim-latex} is a  Vim plugin which provides a rich tool of
features for editing latex files.")
      (home-page "http://vim-latex.sourceforge.net/")
      (license license:expat)))) ; Actually, figure this one out.

(define-public vim-snippets
  (let ((commit "60b736b4be089fcb5c90a9ed7943bd4ea8629247")
        (revision "1"))
    (package
      (name "vim-snippets")
      (version (string-append "0.0.0-" revision "." (string-take commit 7)))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/honza/vim-snippets")
               (commit commit)))
         (file-name (string-append name "-" version "-checkout"))
         (sha256
          (base32
           "1mn0xsdl82x37ns53yh4r763praj496181vbbqp3y85wlny3vfpq"))))
      (build-system gnu-build-system)
      (arguments
       `(#:tests? #f
         #:phases
         (modify-phases %standard-phases
           (delete 'configure)
           (delete 'build)
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (vimfiles (string-append out "/share/vim/vimfiles"))
                      (autoload (string-append vimfiles "/autoload"))
                      (plugin (string-append vimfiles "/plugin"))
                      (pythonx (string-append vimfiles "/pythonx"))
                      (snippets (string-append vimfiles "/snippet"))
                      (UltiSnips (string-append vimfiles "/UltiSnips")))
                 (copy-recursively "autoload" autoload)
                 (copy-recursively "plugin" plugin)
                 (copy-recursively "pythonx" pythonx)
                 (copy-recursively "snippets" snippets)
                 (copy-recursively "UltiSnips" UltiSnips)
                 #t))))))
      (synopsis "snipMate and UltiSnip Vim Snippets")
      (description
       "@code{vim-snippets} provides snippet files for various programming
languages to be used with snipMate, UltiSnip or other supported Vim snippet
engines.")
      (home-page "https://github.com/honza/vim-snippets")
      (license license:expat))))

(define-public vim-xoria256
    (package
      (name "vim-xoria256")
      (version "1.5")
      (source
       (origin
         (method url-fetch)
         (uri (string-append "https://github.com/vim-scripts/xoria256.vim/"
                             "archive/" version ".tar.gz"))
         (file-name (string-append name "-" version ".tar.gz"))
         (sha256
          (base32
           "1d8d5jlgybp1kix913mf6lm6blrylgk2qirbwh23xyy99w2c6hn9"))))
      (build-system gnu-build-system)
      (arguments
       `(#:tests? #f
         #:phases
         (modify-phases %standard-phases
           (delete 'configure)
           (delete 'build)
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (vimfiles (string-append out "/share/vim/vimfiles"))
                      (colors (string-append vimfiles "/colors")))
                 (copy-recursively "colors" colors)
                 #t))))))
      (synopsis "Xoria256 color theme for Vim")
      (description
       "@code{vim-xoria256} tries to follow the 'traditional' colour
semantics found in some IDEs: cold (blue-ish) hues for control structures,
warm colors for data, (green would look for comments, but it's difficult
to pick an appropriate value for the dark background with only 256 colors
available plus a little hard to read, so they are grey).  Colors should
look almost similar in vim, running in any modern terminal emulator
(like recent versions of xterm or konsole), and in GTK2 GUI.")
      (home-page "https://github.com/vim-scripts/xoria256.vim")
      (license license:expat))) ; ???

